package com.smart.service.impl;

import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import com.smart.entity.SysCar;
import javax.annotation.Resource;
import com.smart.mapper.CarMapper;
import com.smart.service.CarService;
import com.smart.service.sys.SysCameraService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

/**
 * @author lgb
 * @date 2020年6月12日 上午11:37:21 Copyright (C) 深圳工勘科技
 * @说明: 车serviceImpl
 **/
@Service
public class CarServiceImpl extends BaseServiceImpl<SysCar,Integer> 
		implements CarService {

	@Resource
	private CarMapper carMapper;
	@Resource
	private SysCameraService cameraService;
	/**
	 * (non-Javadoc)
	 * @see: 根据车牌编号查询列表
	 **/
	@Override
	@Transactional(readOnly = true)
	public Map<String, Object> getCarListByUserId(Long userId) {
		Map<String, Object> car = carMapper.getCarListByUserId(userId.intValue());
		if(car != null ){
			if (!car.isEmpty()) {
				Integer dictDetailId = (Integer) car.get("dict_detail_id");
				if (null != dictDetailId) {
					Map<String, Object> c = carMapper.getDictBydcitId(dictDetailId);
					if(c != null ){
						if (!c.isEmpty()) {
							car.put("dict_label", c.get("dict_label"));
							car.put("dict_type", c.get("dict_type"));
						}
					}
				}
			}
		}
		return car;
	}
	@Override
	@Transactional(readOnly=true)
	public List<SysCar> findCarByNo(String no) {
		List<SysCar> list = new ArrayList<SysCar>();
		LambdaQueryWrapper<SysCar> wrapper=new LambdaQueryWrapper<>();
		wrapper.eq(SysCar::getCarNo,no);
		list =  this.baseMapper.selectList(wrapper);
		return list;
	}
	

}